package com.hiultra.archive.service.impl;


import com.hiultra.archive.domain.ArcAccountType;
import com.hiultra.archive.mapper.ArcAccountTypeMapper;
import com.hiultra.archive.service.IArcAccountTypeService;
import com.hiultra.common.exception.ServiceException;
import com.hiultra.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 类型编号Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-16
 */
@Service
public class ArcAccountTypeServiceImpl implements IArcAccountTypeService
{
    @Autowired
    private ArcAccountTypeMapper arcAccountTypeMapper;

    /**
     * 查询类型编号
     * 
     * @param typeCode 类型编号主键
     * @return 类型编号
     */
    @Override
    public ArcAccountType selectArcAccountTypeByTypeCode(Long typeCode)
    {
        return arcAccountTypeMapper.selectArcAccountTypeByTypeCode(typeCode);
    }

    /**
     * 查询类型编号列表
     *
     * @param arcAccountType 类型编号
     * @return 类型编号
     */
    @Override
    public List<ArcAccountType> selectArcAccountTypeList(ArcAccountType arcAccountType)
    {
        return arcAccountTypeMapper.selectArcAccountTypeList(arcAccountType);
    }

    /**
     * 新增类型编号
     * 
     * @param arcAccountType 类型编号
     * @return 结果
     */
    @Override
    public int insertArcAccountType(ArcAccountType arcAccountType)
    {
        ArcAccountType accountType = arcAccountTypeMapper.selectArcAccountTypeByTypeName(arcAccountType.getTypeName());
        if (StringUtils.isNotNull(accountType)) {
            throw new ServiceException("户号" + accountType.getTypeName() + "已存在，无法新增！");

        }
        return arcAccountTypeMapper.insertArcAccountType(arcAccountType);
    }

    /**
     * 修改类型编号
     * 
     * @param arcAccountType 类型编号
     * @return 结果
     */
    @Override
    public int updateArcAccountType(ArcAccountType arcAccountType)
    {
        return arcAccountTypeMapper.updateArcAccountType(arcAccountType);
    }

    /**
     * 批量删除类型编号
     * 
     * @param typeCodes 需要删除的类型编号主键
     * @return 结果
     */
    @Override
    public int deleteArcAccountTypeByTypeCodes(Long[] typeCodes)
    {
        return arcAccountTypeMapper.deleteArcAccountTypeByTypeCodes(typeCodes);
    }

    /**
     * 删除类型编号信息
     * 
     * @param typeCode 类型编号主键
     * @return 结果
     */
    @Override
    public int deleteArcAccountTypeByTypeCode(Long typeCode)
    {
        return arcAccountTypeMapper.deleteArcAccountTypeByTypeCode(typeCode);
    }
}
